var app = getApp()
var utils = require('../../utils/utils.js')
Page( {
  data: {
    userInfo: {},
    userListInfo: [ {
      icon: '../../images/iconfont-dingdan.png',
      text: '我的订单',
      jumpPage:"../personal/userOrder/userOrder",
      isunread: false,
      unreadNum: 2
    }, {
        icon: '../../images/iconfont-shouhuodizhi.png',
        jumpPage:"../personal/userAddress/userAddress?type=init",
        text: '收货地址'
      }, {
      icon: '../../images/iconfont-card.png',
      text: '优惠券',
      jumpPage:"../personal/userCard/userCard",
      isunread: false,
      unreadNum: 1
    }, {
        icon: '../../images/iconfont-kefu.png',
        jumpPage:"../personal/service/service",
        text: '联系客服'
      }, {
        icon: '../../images/iconfont-help.png',
        jumpPage:"../personal/question/question",
        text: '常见问题'
      }]
  },

  onLoad: function() {
    var that = this
    // 获取用户信息
    wx.login({
      success: function (res) {
        //调用后台接口
        var param ={"code":res.code,"appId":app.globalData.appId};
        wx.request({
          url: utils.sysConst.getUserInfoPath,
          method: 'POST',
          header: {
            "Content-Type": "application/x-www-form-urlencoded",'appVersion':utils.appVersion,'signValue':utils.getSignValue(param)
          },
          data: param,
          dataType: "json",
          success: function(res) {
            if (res.data.code == 1){
              //设置全局用户信息-openid
              app.globalData.openid = res.data.data.openid
              console.log("app.globalData.openid-my",app.globalData.openid)
            }else{
              wx.showToast({
                title:"获取用户信息失败："+res.data.msg,
                icon: 'none',
                duration: 2000
              })
            }
          }
        })
        // == getUserInfo end
      }
    });
    //wx.login === end ===
  }
})